import tornado.ioloop
import tornado.web


class IndexHandler(tornado.web.RequestHandler):
    def initialize(self) -> None:
        return super().initialize()

    def get(self):
        self.write('Hello, world111qqq')


class UsersHandler(tornado.web.RequestHandler):
    def initialize(self, names) -> None:
        # breakpoint()
        self.names = names

    def get(self):
        print(self.names)
        self.write('Hello, users')


class ArticlesHandler(tornado.web.RequestHandler):
    # def initialize(self, names) -> None:
    #     return super().initialize()

    def get(self):
        print(self.reverse_url('ars'))
        self.write('Hello, Articles')


def make_app():
    return tornado.web.Application(
        [
            (r'/', IndexHandler),
            (r'/users', UsersHandler, {'names': 'aaa'}),
            tornado.web.url(r'/articles', ArticlesHandler, name='ars'),
            # (r'/user', UsersHandler),

        ],
        debug=True,
        # transforms=[],
        # autoreload=True,
        # static_path="d:/ME/repos/gitee_repo/tornado-stu/static",
        # template_path="d:/ME/repos/gitee_repo/tornado-stu/templates",
        # xsrf_cookies=True,
        # cookie_secret="secret",
        # login_url="/login",
        # cookie_secret="secret",
    )


if __name__ == '__main__':
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()
